function handleData(arr = [], isSum) {
    let sum = 0;
    for (let i = 0; i < arr.length; i++) {
        sum += arr[i];
    }
    return isSum ? sum : sum / arr.length;
}



//测试数组
let arr = [2,15,23,1,4,45,7]
console.log(handleData(arr,false));
console.log(handleData(arr, true));

